package com.sanrenzu.chunbo.ui.fenlei.gengduo;

import android.os.Handler;
import android.os.Looper;

import com.sanrenzu.chunbo.bean.zxb.XinXianBean;
import com.sanrenzu.chunbo.ui.vertical.gengduo.GengDuoContract;

import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by My on 2016/9/1.
 */
public class GengDuoPersenterF implements GengDuoContractF.Persenter {

    private GengDuoContractF.View view;
    private GengDuoContractF.Modle modle;

    public  GengDuoPersenterF(GengDuoContractF.View view){
        this.view=view;
        this.modle=new GengDuoModleF();
    }
    @Override
    public void getVerticalXinXian(Map<String,String> params) {
        modle.getVerticalXinXianBean(params,new Callback<XinXianBean>() {
            @Override
            public void onResponse(Call<XinXianBean> call, Response<XinXianBean> response) {
                final XinXianBean bean = response.body();
                Handler handler = new Handler(Looper.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onGetVerticalXinXianBean(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<XinXianBean> call, Throwable t) {
                t.printStackTrace();
            }
        });
    }
}
